import {enableProdMode} from '@angular/core';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';

import {AppModule} from './app/app.module';
import {environment} from './environments/environment';
import {CommonTool} from './app/common/common.tool';
import {HTTP_URLS} from './app/base/base-http.url';
import {SystemDto} from './app/base/base.model';
import {CommonHttp} from './app/common/common.http';

// 查询系统信息
const commonHttp = new CommonHttp();
if (environment.openBackEnd) {
  const httpModel = commonHttp.get(CommonTool.analysisUrl(HTTP_URLS.getSystemInfoByCode, {systemCode: environment.systemCode}));
  const system = new SystemDto(JSON.parse(httpModel.data));
  document.getElementsByTagName('title')[0].innerText = system.name;
  sessionStorage.setItem(environment.systemKey, JSON.stringify(system));
} else {
  const httpModel = commonHttp.get('/assets/json/system.json');
  const system = new SystemDto(JSON.parse(httpModel.data));
  document.getElementsByTagName('title')[0].innerText = system.name;
  sessionStorage.setItem(environment.systemKey, JSON.stringify(system));
}
if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.error(err));
